Python基础-Hello_world.py
在Win10上使用Geany记录Python入门的基础,包括字符串和数字操作
# ~ coding=UTF-8
# ~ 解决中文注释乱码
# ~ print("hello")
# ~ The Zen of Python, by Tim Peters
# ~ import this
# ~ 转换选中部分大/小写:ctrl+alt+u
# ~ 切换注释:ctrl+e
# ~ 整体缩进:ctrl+i
# ~ 整体撤销缩进:ctrl+u
# ~ 定义变量
# ~ message = "Hello Python world!"
# ~ print(message)
# ~ 字符串
# ~ name = "ada lovelace"
# ~ print(name.title())#首字符大写
# ~ print(name.upper())#所有字符大写
# ~ print(name.lower())#所有字符小写
# ~ 字符串合并
# ~ first_name = "ada"
# ~ last_name = "lovelace"
# ~ full_name = first_name + " " + last_name
# ~ print(full_name)
# ~ 制表符和换行符
# ~ print("Languages:\n\tPython\n\tC\n\tJavaScript")
# ~ 删除空白
# ~ favourate_language = " python "
# ~ print(favourate_language.rstrip())#删除字符串末端的空白
# ~ print(favourate_language.lstrip())#删除字符串前端的空白
# ~ print(favourate_language.strip())#同时删除字符串前后端的空白
# ~ print(favourate_language)#不会改变原变量的值
# ~ favourate_language = favourate_language.rstrip()#改变原变量的值
# ~ 整数
# ~ print(2+3)
# ~ print(3/2)
# ~ print((2+3)**2)
# ~ 浮点数
# ~ print(0.2+2*0.1)
# ~ print(0.1+0.2)
# ~ 将非字符串转换为字符串:str()
# ~ age = 23
# ~ message = "Happy " + str(age) + "rd Birthday!"#不能用age.str()的形式
# ~ print(message)