def inputValue() -> 'all valid info': while True: try: g = input('\nyour gender?\nenter \'m\' for male enter \'f\' for female: '.title()) if g.lower() not in ['m', 'f']: raise ValueError break except ValueError: print('\...
回答于 2021-09-23 23:10
首先,生成list import itertools list1 = list(itertools.permutati**((0,1,2,3,4,5,6,7,8,9),3))
回答于 2021-09-23 23:07
可以编写出来吗?我试过用取余来判断,但是题中有加有减,后面有-(n-1)+n,感觉没有规律,是不是要用数学知识将这个算式分解,再考虑编程
回答于 2021-09-23 23:06
谢谢老师的回复, 结果是正确的, 就是显示的格式希望所有的信息都在一张表格体现出来, 我下面这段代码得到的结果就是希望的结果, 但是是我拼凑起的, 应该代码可以再优化, 老师能否把我下面代码精简优化下, df=pd.DataFrame({'型号':['A','A','A','A','B',], '规格':['H','H','H','H','H'], ...
回答于 2021-09-23 22:14
代碼:prefix = "https://book.douban.com/subject/"address = [2333637, 33409182, 3090244, 4819381, 1054592, 25848514, 2376727, 3069028, 1760297, 2081995, 21, 2278274, 2213619, 3365411, 2081994, 2174072, 3099292]url = [prefix+str(i) for i in address]for i in url: print(i)复制代码輸出:https://book....
回答于 2021-09-23 21:30
第三题: class Singleton(object): __instance = None def __new__(cls, *args, **kwargs): if cls.__instance == None: cls.__instance = super(Singleton, cls).__new__(cls, *args, **kwargs) return cls.__instance s1 = Singleton() s2 = Singleton() print(s1) print(s2)
回答于 2021-09-11 21:05
import os import time import ntplib import socket import subprocess count=0 while count==0: try: c = ntplib.NTPClient() response = c.request('pool.ntp.org') except socket.gaierror: time.sleep(5) print("网络不通\n") continue except ntplib.NTPException: time.sleep(5) print("请...
回答于 2021-08-07 15:47