摘要:
python默认编码格式为ASCII码,不能使用非英文字符 s = '''大湘菜''' print(s) 结果会报错: SyntaxError: Non-UTF-8 code starting with '\xb4' in file D:\Pycharm\pythonProject\main.py 阅读全文
posted @ 2022-04-23 10:17
树叶本子
阅读(1516)
评论(0)
推荐(0)
摘要:
os.access(path, mode) 检验权限模式 os.chdir(path) 改变当前工作目录os.chflags(path, flags) 设置路径的标记为数字标记。os.chmod(path, mode) 更改权限 os.chown(path, uid, gid) 更改文件所有者os. 阅读全文
posted @ 2022-04-23 09:36
树叶本子
阅读(47)
评论(0)
推荐(0)
摘要:
open()方法用于打开一个文件,并返回文件对象,注意最后一定要关闭文件对象,即调用close()方法 一般形式为: open(file, mode= , buffering= , encoding= , errors= , newline= , closefd= , opener= ) 参数说明: 阅读全文
posted @ 2022-04-23 08:52
树叶本子
阅读(121)
评论(0)
推荐(0)
摘要:
输出 1、表达式语句 2、print() 3、write() 美化输出格式 repr()产生一个解释器易读的表达形式: a = 'the sea has bank\nmy love is boundless' print(a) print(repr(a)) # 可以转义特殊字符 结果为: the s 阅读全文
posted @ 2022-04-20 19:46
树叶本子
阅读(391)
评论(0)
推荐(0)
摘要:
python模块是一个py文件,一个模块只会被导入一次 python在编译或安装的时候会确定搜索路径,使用import语句的时候,python解释器就从搜索路径(即一系列目录名)中查找模块 import sys print(sys.argv) # 命令行参数 print(sys.path) # 路径 阅读全文
posted @ 2022-04-20 16:35
树叶本子
阅读(55)
评论(0)
推荐(0)
摘要:
定义函数的一般格式: det function(): statements return a return用于退出函数,向调用方返回一个表达式 函数可以不设置参数,也可以设置参数: def function1(): print('大湘菜') def function2(a): print(a) fu 阅读全文
posted @ 2022-04-19 18:46
树叶本子
阅读(98)
评论(0)
推荐(0)
摘要:
document.getElementById('').remove() document.getElementByClassName('')[i].remove() document.getElementByTagName('')[i].remove() document.getElementBy 阅读全文
posted @ 2022-04-17 16:05
树叶本子
阅读(246)
评论(0)
推荐(0)
摘要:
iter()用于创建迭代器,next()用于输出迭代器的下一个元素: names = ['微湘菜', '小湘菜', '大湘菜', '巨湘菜'] iterName = iter(names) for i in range(4): print(next(iterName)) 结果为: 微湘菜 小湘菜 大 阅读全文
posted @ 2022-04-16 23:18
树叶本子
阅读(88)
评论(0)
推荐(0)
摘要:
while循环 一般形式: while condition: statement1 else: statement2 a = 0 while a < 3: print(a) a = a + 1 else: print(a, " 大于或等于3") 结果为: 0 1 2 3 大于或等于3 无限循环: w 阅读全文
posted @ 2022-04-16 12:31
树叶本子
阅读(178)
评论(0)
推荐(0)
摘要:
if语句的一般形式: if condition1: statement1 elif condition2: statement2 else: statement3 if语句可嵌套: a = 2 if a < 10: if a < 5: print('small') elif a >= 5: prin 阅读全文
posted @ 2022-04-16 09:51
树叶本子
阅读(32)
评论(0)
推荐(0)
浙公网安备 33010602011771号