Python - 将下划线转换为Fullstop

1 python coding-style

将字符串转换'321_1''321.1'.

我想创建一个方法将下划线转换为句号.我使用拆分,但它无法工作..任何人都可以帮助我?或者我必须使用while循环

将下划线转换为fullstop

def Convert_toFullStop(text):

    x1 = ""
    words = text.split()
    if words in ("_"):
        words = "."
    print words
Run Code Online (Sandbox Code Playgroud)

Hon*_*Zhu 7

使用replace()函数?

newtext = text.replace('_','.')
Run Code Online (Sandbox Code Playgroud)