摘要:# 操作列表 magicians = ['alice', 'david', 'carolina'] for magician in magicians: # 遍历整个列表 print(magician) print('\n') for magician in magicians: print(magician.title() + ", that was a great...
阅读全文
随笔分类 - 基础Python
Python编程:从入门到实践
摘要:# 列表 由一系列按特定顺序排列的元素组成。 bicycles = ['trek', 'cannondale', 'redline', 'specialized'] print(bicycles) # 访问列表元素 print(bicycles[0]) print(bicycles[0].title()) # 索引从0而不是1开始 print(bicycles[1]) print(bicyc...
阅读全文
摘要:# 字符串: # 修改字符串的大小写: name = "ada lovelace" print(name.title()) # 可以将首字母转换为大写; print(name.lower()) print(name.upper()) # 合并(拼接)字符串: first_name = "ada" last_name = "lovelace" full_name = first_n...
阅读全文
摘要:# 整数 # 可对整数执行+、-、*、/运算,**表示乘方; # 浮点数 print(3 * 0.1) # 0.30000000000000004; print(0.2 + 0.1) # 0.30000000000000004;这是一个问题,后面会有解决 age = 23 # message = "Happy " + age + "rd Birthday!" # print(messa...
阅读全文
摘要:# 变量的命名和使用: # 变量名只能包含字母、数字、下划线,只能以下划线和字母开头; # 变量名不能包含空格; # 不要将函数名和关键字作为变量名; # 变量名应该即简短又具有描述性; message = "hello python world!" print(message) message = "hello python crash course world!" print(mess...
阅读全文
摘要:print("hello python world!")
阅读全文
摘要:The Zen of Python, by Tim Peters Beautiful is better than ugly.Explicit is better than implicit.Simple is better than complex.Complex is better than c
阅读全文

浙公网安备 33010602011771号