Python笔记--查找以及更改python解析器的位置

Python017

Python笔记--查找以及更改python解析器的位置,第1张

1.

2.

3.图中箭头所指即为python解析器的位置

4.在pychram:file-settings-python interpreter-设置-add-new environment-base interpreter将路径粘到这里选择exe文件-existing environment同理

字符

使用rfind()和rindex()方法可以找到特定字符的位置,然后可以使用切片操作查找左右字符:

str = 'Hello World'

# 找到字符o的位置

pos = str.rfind('o')

# 查找字符o左右字符

left_char = str[pos-1]

right_char = str[pos+1]

print(left_char,right_char)

# 输出:l d右字符

使用rfind()和rindex()方法可以找到特定字符的位置,然后可以使用切片操作查找左右字符:

str = 'Hello World'

# 找到字符o的位置

pos = str.rfind('o')

# 查找字符o左右字符

left_char = str[pos-1]

right_char = str[pos+1]

print(left_char,right_char)

# 输出:l d