TypeError : Flask의 'str'및 'float'개체를 MySQL과 연결할 수 없습니다.

NWOWN

MySQL 및 Flask에서 Python 코드를 작동합니다.

사용자가 웹에서 위치 이름과 반경을 입력하면 Python 코드는 MySQL에서 반경 내에있는 위치 및 기타 위치에 대한 정보를 검색합니다.

내 코드는 다음과 같습니다.

'이름'은 사용자가 입력 한 위치 이름입니다.
'ron'은 사용자가 입력 한 반경입니다.

 @app.route('/index', methods=["GET","POST"])
 def search_location(names, ron):
    row2=[]
    dis=ron/100
    cur = mysql.connect().cursor()
    cur.execute("select * from map_info where loc_name = '"+names+"'")
    info_db = cur.fetchall()

    cur.execute("select mapY, mapX from map_info where loc_name = '"+names+"'")
         for row in cur:
             print row
    row2.append(float(row[0]))
    row2.append(float(row[1]))
    row2.append(int(dis))

    cur.execute("select loc_name, mapY, mapX ( 6371 * acos( cos( radians("+row2[0]+ ") * cos( radians( mapY ) ) * cos( radians( mapX )- radians("+row2[1]+"))+ sin( radians("+row2[0]+") ) * sin( radians( mapY ) ) ) ) as distance FROM map_info HAVING distance < "+row2[2])

return render_template('index.html', results=info_db, rons=ron)

그러나 'TypeError : cannot concatenate'str 'and'float 'objects'는 반경 내 위치를 검색하는 마지막 SQL 문에서 발생합니다.

어떻게 고칠 수 있습니까?
당신의 조언에 감사드립니다.

망가 트 라이 모디

row2[]입니다 Float하지만 당신은 그것을 연결하는 노력하고있다 String. 파이썬에는 엄격한 유형 검사가 있습니다 (암시 적 유형 변환 없음). 해결책은 row2[index]문자열 로 변경 하는 것입니다. 이 시도:-

cur.execute("select loc_name, mapY, mapX ( 6371 * acos( cos( radians("+str(row2[0])+ ") * cos( radians( mapY ) ) * cos( radians( mapX )- radians("+str(row2[1])+"))+ sin( radians("+str(row2[0])+") ) * sin( radians( mapY ) ) ) ) as distance FROM map_info HAVING distance < "+str(row2[2]))

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

TypeError : 'str'및 'float'개체를 연결할 수 없습니다. : Pandas

분류에서Dev

TypeError : '<class'str '>'유형의 개체를 연결할 수 없습니다. Series 및 DataFrame obj 만 유효합니다.

분류에서Dev

TypeError : 'str'및 'function'객체를 연결할 수 없습니다.

분류에서Dev

Tkinter Label, TypeError : 'str'및 'instance'개체를 연결할 수 없습니다.

분류에서Dev

Python Selenium TypeError : 'str'및 'WebElement'개체를 연결할 수 없습니다.

분류에서Dev

Python : TypeError : 'str'과 'int'를 연결할 수 없습니다.

분류에서Dev

Python TypeError : 인쇄를 시도 할 때 'str'및 'int'개체를 연결할 수 없습니다.

분류에서Dev

re.search () TypeError : 'str'및 'NoneType'객체를 연결할 수 없습니다.

분류에서Dev

TypeError : scrapy.Request ()에 맞춤 URL을 배치 할 때 'str'및 'NoneType'개체를 연결할 수 없습니다.

분류에서Dev

TypeError : 'str'과 'NoneType'객체를 연결할 수 없습니다 .python BS4

분류에서Dev

Python TypeError : 메시지의 이메일 본문 부분에서 'str'및 'list'개체를 연결할 수 없습니다.

분류에서Dev

TypeError : 'float'개체를 str 암시 적으로 변환 할 수 없거나 TypeError :-: 'str'및 'float'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

형식 오류는 'str'및 'ErrorList'개체를 연결할 수 없습니다.

분류에서Dev

Python 오류 : 'str'및 'builtin_function_or_method'개체를 연결할 수 없습니다.

분류에서Dev

TypeError : 'str'개체는 MySQL에서 호출 할 수 없습니다.

분류에서Dev

openerp는 'str'과 'function'객체를 연결할 수 없습니다.

분류에서Dev

TypeError : str에 바이트를 연결할 수 없습니다.

분류에서Dev

TypeError : DataFrame에서 str ( "float"아님) 만 str에 연결할 수 있습니다.

분류에서Dev

django-selenium TypeError : 'str'개체를 호출 할 수 없습니다.

분류에서Dev

TypeError : 'ObjectId'유형의 개체는 Flask 및 MongoDB를 사용하여 JSON 직렬화 할 수 없습니다.

분류에서Dev

Python에서 str과 int를 연결할 수 없습니다.

분류에서Dev

xml에 디렉터리 목록- 'str'및 'NoneType'개체를 연결할 수 없습니다. 처리 방법?

분류에서Dev

TypeError : 'float'유형의 객체에는 len ()이 없습니다. & TypeError : 'float'객체는 반복 할 수 없습니다.

분류에서Dev

discord.py TypeError에 문제가 있습니다 : str ( "float"아님) 만 str에 연결할 수 있습니다.

분류에서Dev

TypeError : print를 호출 할 때 'str'개체를 호출 할 수 없습니다.

분류에서Dev

" 'float'개체를 암시 적으로 str로 변환 할 수 없습니다."

분류에서Dev

TypeError : 필드 값 : FloatType은 <class 'numpy.float64'> 유형의 -0.016354798954796402 개체를 허용 할 수 없습니다.

분류에서Dev

python "TypeError : 'numpy.float64'개체를 정수로 해석 할 수 없습니다."

분류에서Dev

TypeError : 'list'개체를 암시 적으로 str로 변환 할 수 없습니다.

Related 관련 기사

  1. 1

    TypeError : 'str'및 'float'개체를 연결할 수 없습니다. : Pandas

  2. 2

    TypeError : '<class'str '>'유형의 개체를 연결할 수 없습니다. Series 및 DataFrame obj 만 유효합니다.

  3. 3

    TypeError : 'str'및 'function'객체를 연결할 수 없습니다.

  4. 4

    Tkinter Label, TypeError : 'str'및 'instance'개체를 연결할 수 없습니다.

  5. 5

    Python Selenium TypeError : 'str'및 'WebElement'개체를 연결할 수 없습니다.

  6. 6

    Python : TypeError : 'str'과 'int'를 연결할 수 없습니다.

  7. 7

    Python TypeError : 인쇄를 시도 할 때 'str'및 'int'개체를 연결할 수 없습니다.

  8. 8

    re.search () TypeError : 'str'및 'NoneType'객체를 연결할 수 없습니다.

  9. 9

    TypeError : scrapy.Request ()에 맞춤 URL을 배치 할 때 'str'및 'NoneType'개체를 연결할 수 없습니다.

  10. 10

    TypeError : 'str'과 'NoneType'객체를 연결할 수 없습니다 .python BS4

  11. 11

    Python TypeError : 메시지의 이메일 본문 부분에서 'str'및 'list'개체를 연결할 수 없습니다.

  12. 12

    TypeError : 'float'개체를 str 암시 적으로 변환 할 수 없거나 TypeError :-: 'str'및 'float'에 대해 지원되지 않는 피연산자 유형

  13. 13

    형식 오류는 'str'및 'ErrorList'개체를 연결할 수 없습니다.

  14. 14

    Python 오류 : 'str'및 'builtin_function_or_method'개체를 연결할 수 없습니다.

  15. 15

    TypeError : 'str'개체는 MySQL에서 호출 할 수 없습니다.

  16. 16

    openerp는 'str'과 'function'객체를 연결할 수 없습니다.

  17. 17

    TypeError : str에 바이트를 연결할 수 없습니다.

  18. 18

    TypeError : DataFrame에서 str ( "float"아님) 만 str에 연결할 수 있습니다.

  19. 19

    django-selenium TypeError : 'str'개체를 호출 할 수 없습니다.

  20. 20

    TypeError : 'ObjectId'유형의 개체는 Flask 및 MongoDB를 사용하여 JSON 직렬화 할 수 없습니다.

  21. 21

    Python에서 str과 int를 연결할 수 없습니다.

  22. 22

    xml에 디렉터리 목록- 'str'및 'NoneType'개체를 연결할 수 없습니다. 처리 방법?

  23. 23

    TypeError : 'float'유형의 객체에는 len ()이 없습니다. & TypeError : 'float'객체는 반복 할 수 없습니다.

  24. 24

    discord.py TypeError에 문제가 있습니다 : str ( "float"아님) 만 str에 연결할 수 있습니다.

  25. 25

    TypeError : print를 호출 할 때 'str'개체를 호출 할 수 없습니다.

  26. 26

    " 'float'개체를 암시 적으로 str로 변환 할 수 없습니다."

  27. 27

    TypeError : 필드 값 : FloatType은 <class 'numpy.float64'> 유형의 -0.016354798954796402 개체를 허용 할 수 없습니다.

  28. 28

    python "TypeError : 'numpy.float64'개체를 정수로 해석 할 수 없습니다."

  29. 29

    TypeError : 'list'개체를 암시 적으로 str로 변환 할 수 없습니다.

뜨겁다태그

보관