社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

Patrick

Patrick 最近回复了
2 年前
回复了 Patrick 创建的主题 » 我需要用python替换SQL文件中的某个数字

如果您是从脚本运行查询,那么下面的函数可能是更改查询的更有用的方法

import pyodbc

def run_query(number):
    query = f"SELECT * FROM public.flores_comahue WHERE codigo_postal::int > {number}"
    conn = pyodbc.connect(server_connection) # some connection
    results = pd.read_sql_query(query, conn) # run query
    conn.close()
    return restults

这只是一个如何实现的示例,但一般来说,构造一个查询字符串应该可以解决您的问题

2 年前
回复了 Patrick 创建的主题 » 如何设置GitLab页面暂存区(无需登录即可看到?)

是的,您可以将“页面”功能设置为公共,而存储库本身保持私有。要这样做,请访问 Settings > General ,然后设置 Project visibility 私下里,然后 Pages 给大家。

2 年前
回复了 Patrick 创建的主题 » 我的Python温度转换器不工作

这里有两个问题,第一个是 getinput() 不返回导致错误的内容

TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'

第二个问题是代码不打印结果,您可以从函数内部打印结果,也可以像这样调用函数调用的print

def getinput():
    print("Enter the temperature")
    a = float(input())
    return a
def Converter():
    print("Press 1 for Fahrenheit to Celsius\nPress 2 for Celsius to Fahrenheit")
    x = int(input())
    if x == 1:
       a = getinput()
       return (a - 32) * 5/9
    if x == 2:
        a = getinput()
        return (a + 32) * 9/5

print(Converter())

输出示例:

Press 1 for Fahrenheit to Celsius
Press 2 for Celsius to Fahrenheit

1
Enter the temperature

23
-5.0

作为一个需要注意的小问题 input() 将消息作为参数

def getinput():
    return float(input("Enter the temperature: "))
def Converter():
    x = int(input("Press 1 for Fahrenheit to Celsius\nPress 2 for Celsius to Fahrenheit\n"))
    if x == 1:
       a = getinput()
       return (a - 32) * 5/9
    if x == 2:
        a = getinput()
        return (a + 32) * 9/5

print(Converter())

现在 getinput() 这是相当多余的

def Converter():
    x = int(input("Press 1 for Fahrenheit to Celsius\nPress 2 for Celsius to Fahrenheit\n"))
    if x == 1:
       a = float(input("Enter the temperature: "))
       return (a - 32) * 5/9
    if x == 2:
        a = float(input("Enter the temperature: "))
        return (a + 32) * 9/5

print(Converter())
11 年前
回复了 Patrick 创建的主题 » bitbucket中的Git显示了文件之间的巨大差异

这通常意味着行尾不同。大多数diffin程序允许您忽略行尾的差异。你的允许你这么做吗?

3 年前
回复了 Patrick 创建的主题 » 如何在html中使用django和js中的变量?

可以在双引号中转义双引号,如下所示 "abc\"def\"ghi" 这将导致 abc“def”ghi .这能解决你的问题吗?

for (var i = 0; i < input.files.length; ++i) {
     selected_files.push(input.files.item(i))
     children += "<form id=\"${input.files.item(i).name}\" -edit-form action=\"{% url 'asset-batch-update' %}\" method=\"POST\">";
}
3 年前
回复了 Patrick 创建的主题 » 如何在docker图像创建过程中回显号码?[重复]

我最近在一个Dockerfile建筑中找到了以下解决方案 Cingulata 图书馆:

ln -snf /usr/share/zoneinfo/$(curl https://ipapi.co/timezone) /etc/localtime

它基本上使用ipapi提供的API。co检索时区信息。这会自动正确配置时区,而不是跳过对话框并使用默认值(UTC)。

5 年前
回复了 Patrick 创建的主题 » jquery tagit验证输入是否为数字
$.isNumeric( "-10" )

返回true。

https://api.jquery.com/jQuery.isNumeric/