程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python web development 02

編輯:Python

pip Export the installation package

Use the following command Will the current python All third-party packages in the environment Export to txt file
pip freeze > requirements.txt
Use the following command to txt Third party packages in files
pip install -r requirements.txt

jpype call jar package

Environmental Science :python 3.6.8 + jpype1 0.6.3 + jdk 1.8

""" The basic development process is as follows : ①、 Use jpype Turn on jvm ②、 load java class ③、 call java Method ④、 close jvm( Not really closed , Unload the previously loaded class ) """
# ①、 Use jpype Turn on virtual machine ( In the open jvm Before loading the classpath )
# Just loaded jar file 
path = r"C:\Users\Administrator\Desktop\my_floder\software_match\software_data\jwtdemo-with-dependencies.jar"
jarpath = os.path.join(os.path.abspath('views'), path)
# obtain jvm.dll File path 
jvmPath = jpype.getDefaultJVMPath()
# jvmPath = 'C:/Program Files/Java/jdk1.8.0_291/jre/bin/server/jvm.dll'
# Turn on jvm
jpype.startJVM(jvmPath, "-ea", "-Djava.class.path=%s" % (jarpath))
# ②、 load java class ( Parameter is java Long class name )
javaClass = jpype.JClass("com.it.zty.JwtUtils")
# Instantiation java object 
# javaInstance = javaClass()
# ③、 call java Method , Because I write static methods , Methods can be called directly using the class name 
user_id = javaClass.getUserId(token)
# ④、 close jvm
jpype.shutdownJVM()

Pay attention to is :python Number of digits and jdk The number of digits must remain the same , Otherwise it will throw
Process finished with exit code -1073741819 (0xC0000005)
Error of .


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved