Форум сайта python.su
Добрый день! Возник такой вопрос: Представим ситуацию, что делаем сайт рекламы какого то продукта например(молоко) и вот на сайте есть статьи о том как питаются коровы, как за ними ухаживают ну и т.д. Блог естественно отображается из БД. Внимание вопрос! Как в посте вывести в нужном месте изображение? И возможно ли это? Те. Идет тест(два три абзаца) потом картинка потом текст(2-3 абзаца) ну и т.д.
P.S. вчера на stackoverflow подсказали, что HTML код можно вписать прям в админку и все заработает, так и поступил.Заработало. А со стороны профессионального взгляда это правильно? Или это велосипед с квадратными колесами?
import jpype import jaydebeapi jHome = jpype.getDefaultJVMPath() jpype.startJVM(jHome, '-Djava.class.path='+PATH_LIB) conn = jaydebeapi.connect('oracle.jdbc.driver.OracleDriver', URL_CONNECTION,[USERNAME,PASSWORD]) curs = conn.cursor() curs.execute(sql_script) ....
Traceback (most recent call last): File "C:/Server/repositories/projects/um/templates/DB/Oracle/Oracle_JDBC.py", line 84, in <module> jpype.startJVM(jHome, '-Djava.class.path='+PATH_LIB) File "C:\Python36\lib\site-packages\jpype\_core.py", line 50, in startJVM _jpype.startup(jvm, tuple(args), True) RuntimeError: Unable to load DLL [C:\Program Files\Java\jre1.8.0_131\bin\server\jvm.dll], error = The specified module could not be found. at native\common\include\jp_platform_win32.h:58
import matplotlib.pyplot as plt all_in = [] file = open('iris.docx', 'r') #Edgar Anderson's Iris Data (Iris.scv) file_tmp = [line.strip() for line in file] file.close() fer = '' temp = '' for i in range(len(file_tmp)): fer = file_tmp[i] for j in range(len(fer)): if j == (len(fer)-1): temp+=fer[j] all_in.append(temp) temp = '' elif fer[j] != ',': temp+=fer[j] elif fer[j] == ',': all_in.append(temp) temp = '' fer = '' Sepal.Length = [] Sepal.Width = [] Petal.Length = [] Petal.Width= [] Species = [] while True: if all_in == []: break Sepal.Length.append(all_in[0]) Sepal.Width.append(all_in[1]) Petal.Length.append(all_in[2]) Petal.Width.append(all_in[3]) Species.append(all_in[4]) all_in.pop(0) all_in.pop(0) all_in.pop(0) all_in.pop(0) all_in.pop(0) for i in range(len(Sepal.Length)): temp = int(Sepal.Length[i]) Sepal.Length.pop(i) Sepal.Length.insert(i, temp) for i in range(len(Sepal.Width)): temp = int(Sepal.Length[i]) Sepal.Width.pop(i) Sepal.Width.insert(i, temp) for i in range(len(Petal.Length)): temp = int(Petal.Length[i]) Petal.Length.pop(i) Petal.Length.insert(i, temp) for i in range(len(Petal.Width)): temp = int(Petal.Width[i]) Petal.Width.pop(i) Petal.Width.insert(i, temp) for i in range(len(Species)): temp = int(Species[i]) Species.pop(i) Species.insert(i, temp) fig, ax = plt.subplots() for color in ['red']: ax.scatter(Sepal.Length, Petal.Length, c=color, label=color, alpha=0.3, edgecolors='none') ax.legend() ax.grid(True) plt.show()
tux = pg.image.load("alienBeige.png")
tux = pg.transform.scale(tux,(100,100))
go = True
while go:
mx,my = pg.mouse.get_pos()
for event in pg.event.get():
if event.type == pg.MOUSEBUTTONDOWN:
if Player.rect.collidepoint(event.pos):
Player.click = True
print("New coordinate",event.pos)
elif event.type == pg.MOUSEBUTTONUP:
Player.click = False
print("Old coordinate",event.pos)
elif event.type == pg.QUIT:
go = False
Screen.fill(0) #!
Screen.blit(tux,(mx-50,my-50))
Player.update(Screen)
pg.display.update()
pg.display.flip()
tux = pg.image.load("alienBeige.png")
tux = pg.transform.scale(tux,(100,100))
go = True
while go:
mx,my = pg.mouse.get_pos()
for event in pg.event.get():
if event.type == pg.MOUSEBUTTONDOWN:
if Player.rect.collidepoint(event.pos):
Player.click = True
print("New coordinate",event.pos)
elif event.type == pg.MOUSEBUTTONUP:
Player.click = False
print("Old coordinate",event.pos)
elif event.type == pg.QUIT:
go = False
Screen.fill(0) #!
Screen.blit(tux,(mx-50,my-50))
Player.update(Screen)
pg.display.update()
pg.display.flip()
""" Embedded Python Blocks: Each time this file is saved, GRC will instantiate the first class it finds to get ports and parameters of your block. The arguments to __init__ will be the parameters. All of them are required to have default values! """ import numpy as np from gnuradio import gr import threading class blk(gr.sync_block): # other base classes are basic_block, decim_block, interp_block """Embedded Python Block example - a simple multiply const""" def __init__(self, example_param=1.0): # only default arguments here """arguments to this function show up as parameters in GRC""" gr.sync_block.__init__( self, name='Embedded Python Block', # will show up in GRC in_sig=[], out_sig=[np.complex64]a ) self.arr= np.loadtxt('txt.dat') print (self.arr) self.maszero = np.zeros(1024,dtype=float) for i in self.arr: self.maszero[i]=10.0 self.s=np.fft.ifft(self.maszero).reshape(1024,) #np.savetxt('txt1.dat',self.s) np.set_printoptions(threshold=np.nan) print (self.s.shape) #for i in self.s: #np.savetxt('txt1.dat', i) # if an attribute with the same name as a parameter is found, # a callback is registered (properties work, too). self.example_param = example_param def work(self, input_items, output_items): out= output_items[0] for i in np.arange(self.s.size): out[i]=self.s[i] return len(output_items[0])
class LoginFormView(FormView): form_class = AuthenticationForm template_name = "login.html" success_url = "/" def form_valid(self, form): self.user = form.get_user() login(self.request, self.user) return super(LoginFormView, self).form_valid(form) def form_invalid(self, form): return super(LoginFormView, self).form_invalid(form)
class ProfileView(LoginRequiredMixin, DetailView): model = User template_name = 'profile.html' pk_url_kwarg = 'user_pk'
class UpdateProfileView(LoginRequiredMixin, UpdateView): form_class = UpdateForm model = User template_name = 'profile_update.html' pk_url_kwarg = 'user_pk' def get(self, request, *args, **kwargs): user = User.objects.get(pk=self.kwargs['user_pk']) if user != request.user: return HttpResponseForbidden() else: return super(UpdateProfileView, self).get(request, *args, **kwargs) def get_success_url(self): return reverse('profile_update', kwargs={'user_pk': self.kwargs['user_pk']})
url(r'^profile/(?P<user_pk>\d+)/$', ProfileView.as_view(), name='profile')
<li><a href="{% url 'profile' user_pk=user.pk %}">профиль</a></li>
import os import arcpy arcpy.CheckOutExtension("spatial") flowdir = "C:\\kkk\\flowdir" for root, dirs, files in os.walk('C:\\hhh'): for f in dirs: r = os.path.join(root,f) print r Output_raster = "C:\\fff\\W_{}".format(f) print Output_raster Output_table = "C:\\fff\\Z_{}".format(f) print Output_table arcpy.gp.Watershed_sa(flowdir, r, Output_raster, "VALUE" ) arcpy.gp.ZonalGeometryAsTable_sa(Output_raster, "VALUE", Output_table, "8,33333333333333E-04" ) print'End {}'.format(f) print '------------' print'End all'
from Tkinter import * import tkFileDialog import os import arcpy arcpy.CheckOutExtension("spatial") def Quit(ev): global root root.destroy() def LoadFile_SPP(ev): global SPP SPP = tkFileDialog.askdirectory() if SPP == '': return def LoadFile_FD(ev): global flowdir flowdir = tkFileDialog.askdirectory() if flowdir == '': return def SaveDir(ev): global SD SD = tkFileDialog.askdirectory() if SD == '': return def ProgWork(ev): for ddd, dirs, files in os.walk(SPP): for f in dirs: r = ddd + '/' + f print r Output_raster = SD + '/' +'Raster_' + f Output_table = SD + '/' +'ZGaT_' + f print Output_raster print Output_table print'Start {}'.format(f) arcpy.gp.Watershed_sa(flowdir, r, Output_raster, "VALUE") print'Stap {}'.format(f) arcpy.gp.ZonalGeometryAsTable_sa(Output_raster, "VALUE", Output_table, "8,33333333333333E-04" ) print'End {}'.format(f) print '------------' print'End all' root = Tk() panelFrame = Frame(root, height = 100, width = 500, bg = 'gray') panelFrame.pack(side = 'top', fill = 'x') loadSPPBtn = Button(panelFrame, text = 'LoadFile_SPP') loadFdBtn = Button(panelFrame, text = 'LoadFile_FD') saveBtn = Button(panelFrame, text = 'Save Directory') calculationBtn = Button(panelFrame, text = 'Calculation') quitBtn = Button(panelFrame, text = 'Quit') loadSPPBtn.bind("<Button-1>", LoadFile_SPP) loadFdBtn.bind("<Button-1>", LoadFile_FD) saveBtn.bind("<Button-1>", SaveDir) calculationBtn.bind("<Button-1>", ProgWork) quitBtn.bind("<Button-1>", Quit) loadSPPBtn.place(x = 10, y = 10, width = 80, height = 40) loadFdBtn.place(x = 100, y = 10, width = 80, height = 40) saveBtn.place(x = 190, y = 10, width = 90, height = 40) calculationBtn.place(x = 290, y = 10, width = 80, height = 40) quitBtn.place(x = 390, y = 10, width = 80, height = 40) root.mainloop()