OSX从Pthon 2.7升级到3.8
1,官网下载最新安装包安装
2,执行认证文件command
3,执行设置path command
4,设置默认python
在terminal里运行open ~/.bash_profile,打开~/.bash_profile,直接修改文件保存,重启Terminal。
source ~/.bash_profile
# Setting PATH for Python 3.8
# The original version is saved in .bash_profile.pysave
export PATH=$PATH:/Library/Frameworks/Python.framework/Versions/3.8/bin:
alias python="/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8"
Print练习
>>> print("hello world") hello world >>> >>> >>> ms="good morning" >>> print(ms) good morning >>> >>> >>> ms=2 >>> print(ms) 2
字符串操作
title:首字母大写
upper:全大写
lower:全小写
strip:去掉两头空格
lstrip:去掉左边空格
rstrip:去掉右边空格
+:链接字符串
>>> ms="li xiaobin" >>> >>> print(ms.upper()) LI XIAOBIN >>> >>> print(ms.lower()) li xiaobin >>> >>> print(ms.title()) Li Xiaobin >>> >>> ms=" li xiao bin " >>> >>> print(ms.strip()) li xiao bin >>> >>> print(ms) li xiao bin >>> print(ms.lstrip()) li xiao bin >>> >>> print(ms.rstrip()) li xiao bin >>> >>> >>> print('li'+ms) li li xiao bin >>>
代码注释
# hello world print("hello ¥n li xiaobin")
如果多行注释可以使用如下方法:
''' many lines hello world by lixiaobin ''' print("hello ¥n li xiaobin")
每天成就一小步,积累下来就是一大步。
转发本文请注明出处,谢谢您的阅读与分享!