×ðÁú¿­Ê±¹ÙÍøµÇ¼

ÔÚLinuxϵͳÉÏʹÓÃPyCharm¾ÙÐÐWeb¿ª·¢µÄÉèÖÃÒªÁì

ÔÚlinuxϵͳÉÏʹÓÃpycharm¾ÙÐÐweb¿ª·¢µÄÉèÖÃÒªÁì

Ëæ×Å»¥ÁªÍøµÄÉú³¤£¬Web¿ª·¢±äµÃÔ½À´Ô½Ö÷Òª¡£¶øPyCharm×÷Ϊһ¿îÇ¿Ê¢µÄPython¼¯³É¿ª·¢ÇéÐΣ¨IDE£©£¬ÔÚWeb¿ª·¢ÁìÓòÒ²»ñµÃÁËÆÕ±éÓ¦Óᣱ¾ÎĽ«ÏÈÈÝÔÚlinuxϵͳÉÏʹÓÃpycharm¾ÙÐÐweb¿ª·¢µÄÉèÖÃÒªÁ죬²¢¸½´ø´úÂëʾÀý£¬×ÊÖú¶ÁÕßÇáËÉÉÏÊÖ¡£

×°ÖÃPyCharm

PyCharm¿ÉÒÔ´ÓÆä¹Ù·½ÍøÕ¾£¨https://www.jetbrains.com/pycharm/£©ÏÂÔØ¡£Ñ¡ÔñÊʺÏÄãLinuxϵͳµÄ°æ±¾£¬ÏÂÔغóƾ֤ÌáÐѾÙÐÐ×°Öá£

½¨ÉèÐÂÏîÄ¿

·­¿ªPyCharm£¬µã»÷”Create New Project”°´Å¥£¬È»ºóÑ¡ÔñÒ»¸öºÏÊʵÄÏîĿĿ¼£¬²¢ÎªÏîÄ¿ÃüÃû¡£Ñ¡ÔñÏîÄ¿Ú¹ÊÍÆ÷ΪPython 3.x¡£

ÉèÖÃÐéÄâÇéÐÎ

ΪÁË×èÖ¹ÓëÆäËûÏîÄ¿µÄÒÀÀµ³åÍ»£¬ÎÒÃÇÐèÒª½¨ÉèÒ»¸öÐéÄâÇéÐΡ£ÔÚPyCharmÖУ¬µã»÷”File -> Settings”·­¿ªÉèÖô°¿Ú£¬È»ºóÑ¡Ôñ”Project: [ÏîÄ¿Ãû³Æ] -> Python Interpreter”¡£µã»÷ÓÒÉϽǵijÝÂÖͼ±ê£¬Ñ¡Ôñ”Add…”£¬È»ºóÑ¡Ôñ”Virtualenv Environment”¡£µã»÷”OK”½¨ÉèÒ»¸öеÄÐéÄâÇéÐΡ£

×°ÖÃËùÐèµÄ°ü

ÔÚPyCharmÖУ¬µã»÷”Terminal”°´Å¥£¬·­¿ªÖնˡ£ÔÚÖÕ¶ËÖÐÔËÐÐÒÔÏÂÏÂÁװÖÃËùÐèµÄ°ü¡£´Ë´¦ÒÔDjangoΪÀý£º

$ pip install django

µÇ¼ºó¸´ÖÆ

ÉèÖÃÔËÐÐÇéÐÎ

ÔÚPyCharmÖУ¬µã»÷”Run -> Edit Configurations”·­¿ªÉèÖô°¿Ú¡£µã»÷”+”°´Å¥£¬ÔÚµ¯³öµÄ¶Ô»°¿òÖÐÑ¡Ôñ”Django Server”¡£ÉèÖÔName”Ϊ”Run Server”£¬”Host”Ϊ”localhost”£¬”Port”Ϊ”8000″¡£µã»÷”OK”ÉúÑÄÉèÖá£

½¨ÉèDjangoÓ¦ÓÃ

ÔÚPyCharmµÄÖÕ¶ËÖÐÔËÐÐÒÔÏÂÏÂÁ½¨ÉèÒ»¸öDjangoÓ¦Óᣴ˴¦ÒÔÃûΪ”myapp”µÄÓ¦ÓÃΪÀý£º

$ python manage.py startapp myapp

µÇ¼ºó¸´ÖÆ

±àд´úÂë

ÔÚPyCharmµÄÏîÄ¿´°¿ÚÖУ¬ÕÒµ½¸Õ¸Õ½¨ÉèµÄÓ¦Ó㨔myapp”£©£¬È»ºóÔÚ¸ÃÓ¦ÓõÄĿ¼Öбàд´úÂë¡£ÀýÈ磬ÔÚ”myapp”Ŀ¼Ï½¨ÉèÒ»¸öÃûΪ”views.py”µÄÎļþ£¬²¢±àдÒÔÏ´úÂ룺

from django.http import HttpResponse

def index(request):
    return HttpResponse("Hello, world!")

µÇ¼ºó¸´ÖÆ

ÉèÖÃURL

ÔÚPyCharmµÄÏîÄ¿´°¿ÚÖУ¬ÕÒµ½ÏîÄ¿µÄ¸ùĿ¼£¬È»ºóÔÚ¸ÃĿ¼ÖÐÕÒµ½ÃûΪ”urls.py”µÄÎļþ¡£·­¿ª¸ÃÎļþ£¬²¢½«ÒÔÏ´úÂëÌí¼Óµ½ÎļþµÄĩβ£º

from django.urls import path
from myapp import views

urlpatterns = [
    path('', views.index, name='index'),
]

µÇ¼ºó¸´ÖÆ

ÉúÑÄÎļþ¡£

ÔËÐÐÏîÄ¿

ÔÚPyCharmÖУ¬µã»÷”Run -> Run”ÔËÐÐÏîÄ¿¡£È»ºóÔÚä¯ÀÀÆ÷Öлá¼û”http://localhost:8000″£¬¼´¿É¿´µ½Ò³ÃæÏÔʾ”Hello, world!”¡£

ͨ¹ýÒÔÉÏ°ì·¨£¬ÎÒÃÇÀÖ³ÉÉèÖÃÁËÔÚLinuxϵͳÉÏʹÓÃPyCharm¾ÙÐÐWeb¿ª·¢µÄÇéÐΣ¬²¢ÇÒÌí¼ÓÁËÒ»¸ö¼òÆÓµÄDjangoÓ¦Ó᣶ÁÕß¿ÉÒÔƾ֤×Ô¼ºµÄÏÖʵÐèÇ󣬽øÒ»²½¿ª·¢²¢ÓÅ»¯¸ÃÓ¦Óá£

×ܽá

±¾ÎļòÒªÏÈÈÝÁËÔÚlinuxϵͳÉÏʹÓÃpycharm¾ÙÐÐweb¿ª·¢µÄÉèÖÃÒªÁ죬²¢Í¨¹ýÒ»¸öDjangoÓ¦ÓõÄÀý×Ó£¬×ÊÖú¶ÁÕßÏàʶÁËÕû¸öÀú³Ì¡£Í¨¹ýʹÓÃPyCharm£¬ÎÒÃÇ¿ÉÒÔÔ½·¢¸ßЧµØ¾ÙÐÐWeb¿ª·¢£¬²¢ÏíÊܵ½ÆäÇ¿Ê¢µÄ¹¦Ð§ºÍ±ãµ±ÐÔ¡£Ï£Íû±¾ÎĶԶÁÕßÓÐËù×ÊÖú£¬²¢ÔÚWeb¿ª·¢µÄõ辶ÉÏÈ¡µÃ¸üºÃµÄЧ¹û£¡

ÒÔÉϾÍÊÇÔÚLinuxϵͳÉÏʹÓÃPyCharm¾ÙÐÐWeb¿ª·¢µÄÉèÖÃÒªÁìµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ