我在使用
Python确定有效的Java包名称时遇到问题.这是代码:
packageName = "com.domain.lala" # valid,not rejected -> correct #packageName = ".com.domain.lala" # invalid,rejected -> correct #packageName = "com..domain.lala" # invalid,not rejected -> incorrect #packageName = "com.domain.lala." # invalid,not rejected -> incorrect matchObject = re.match("([a-z_]{1}[a-z0-9_]*(\.[a-z_]{1}[a-z0-9_]*)*)",packageName) if matchObject is not None: print packageName + " is a package name!" else: print packageName + " is *not* a package name!" Utilities.show_error("Invalid Package Name","Invalid package name " + packageName + "!","Ok","","")
包名称必须以小写字母或下划线开头,每个点后面必须至少再跟一个小写字母或下划线.所有其他字符可以是小写字母,数字或下划线.不允许运行点,它可能不以点结束或以点开头.
我该如何解决这个问题?